var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function s() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (s.prototype = e.prototype, 
    new s());
}), a = this && this.__decorate || function(t, e, o, s) {
    var i, n = arguments.length, r = n < 3 ? e : null === s ? s = Object.getOwnPropertyDescriptor(e, o) : s;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, s); else for (var l = t.length - 1; 0 <= l; l--) (i = t[l]) && (r = (n < 3 ? i(r) : 3 < n ? i(e, o, r) : i(e, o)) || r);
    return 3 < n && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("AudioManager"), s = cc._decorator, c = s.ccclass, l = s.property, d = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.label = null, t.skeleton = null, t.type = 1, t.num = 0, t.total = 180, 
        t.isPause = !1, t;
    }
    return i(t, e), t.prototype.start = function() {
        this.skeleton && (this.skeleton.timeScale = 1.425);
    }, t.prototype.init = function(t) {
        void 0 === t && (t = 180), this.skeleton && this.skeleton.setAnimation(0, "animation", !0), 
        this.endTimer(), this.num = t, this.total = this.num, 6e3 < this.total && (this.type = 2), 
        this.label.node.color = cc.Color.WHITE, this.refresh();
    }, t.prototype.sub = function(t) {
        this.num > t ? this.num -= 20 : (this.num = 0, this.endTimer()), this.refresh();
    }, t.prototype.startTimer = function() {
        this.endTimer(), this.skeleton && (this.skeleton.paused = !1), this.doTimer(), this.schedule(this.doTimer, 1);
    }, t.prototype.doTimer = function() {
        this.isPause || (0 < this.num && this.num--, this.refresh());
    }, t.prototype.endTimer = function() {
        this.skeleton && (this.skeleton.paused = !0), cc.Tween.stopAllByTarget(this.label.node), 
        this.label.node.scale = 1, this.unschedule(this.doTimer);
    }, t.prototype.pauseTimer = function() {
        this.isPause = !0, this.skeleton && (this.skeleton.paused = !0);
    }, t.prototype.resumeTimer = function() {
        this.isPause = !1, this.skeleton && (this.skeleton.paused = !1);
    }, t.prototype.refresh = function() {
        this.label.string = this.parseTime(this.num), 0 === this.num ? (this.node.emit("finished"), 
        this.endTimer()) : this.skeleton && (10 === this.num ? r.default.getInstance().playAudio("倒计时紧张气氛音效") : 30 === this.num && (r.default.getInstance().playAudio("倒计时紧张气氛音效"), 
        this.label.node.color = cc.Color.RED, cc.tween(this.label.node).repeatForever(cc.tween().to(.2, {
            scale: 1.1
        }).to(.2, {
            scale: 1
        }).delay(.6)).start()));
    }, t.prototype.parseTime = function(t) {
        var e, o, s = "";
        1 === this.type ? (s += (e = Math.floor(t / 60)) < 10 ? "0" + e : e, s += ":") : 2 === this.type && (s += (o = Math.floor(t / 3600)) < 10 ? "0" + o : o, 
        s += ":", s += (e = Math.floor(t % 3600 / 60)) < 10 ? "0" + e : e, s += ":");
        t %= 60;
        return s + (t < 10 ? "0" + t : t);
    }, a([ l(cc.Label) ], t.prototype, "label", void 0), a([ l(sp.Skeleton) ], t.prototype, "skeleton", void 0), 
    a([ l ], t.prototype, "type", void 0), a([ c ], t);
}(cc.Component);

n.default = d;